#include "stdafx.h"
#include "phongmaterial.h"

namespace GLC {

PhongMaterial::PhongMaterial(void)
{
    SetDiffuse(1, 1, 1);
    SetAmbient(0.2f, 0.2f, 0.2f);
    SetSpecular(1, 1, 1);
    SetShininess(30);
}

void PhongMaterial::SetDiffuse(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
{
    m_diffuse.x = r;
    m_diffuse.y = g;
    m_diffuse.z = b;
    m_diffuse.w = a;
}

void PhongMaterial::SetAmbient(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
{
    m_ambient.x = r;
    m_ambient.y = g;
    m_ambient.z = b;
    m_diffuse.w = a;
}

void PhongMaterial::SetSpecular(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
{
    m_specular.x = r;
    m_specular.y = g;
    m_specular.z = b;
    m_specular.w = a;
}

void PhongMaterial::SetShininess(GLfloat shininess)
{
    m_shininess = shininess;
}

void PhongMaterial::Activate(GLenum side)const
{
    glMaterialfv(side, GL_DIFFUSE, m_diffuse);
    glMaterialfv(side, GL_AMBIENT, m_ambient);
    glMaterialfv(side, GL_SPECULAR, m_specular);
    glMaterialf(side, GL_SHININESS, m_shininess);
}

} // namespace GLC
